<?php

$this->load->view('layout/header');
$this->load->view('layout/topnav');
?>

<table align="center" width="1000" cellpadding="0" cellspacing="1" style="border:1px solid #CCC">
  <tr bgcolor="#EEE" height="24">
    <td>接口地址</td>
    <td>method</td>
  </tr>
  <tr bgcolor="#F9F9F9" height="24">
    <td><select id="api_host">
<?php
	foreach($hosts as $host){
?>
      <option value="<?php echo $host?>"><?php echo $host?></option>
<?php
	}
?>
    </select><?php echo $api["url"]?></td>
    <td><?php echo $api["method"]?></td>
  </tr>
</table>
<br>
<table align="center" width="1000" cellpadding="0" cellspacing="1" style="border:1px solid #CCC">
  <form id="requestform" method="<?php echo $api["method"]?>">
  <tr bgcolor="#EEE" height="24">
    <td>参数名</td>
    <td>参数</td>
    <td>必填</td>
    <td>类型</td>
    <td>说明</td>
  </tr>
  <tr bgcolor="#F9F9F9" height="24">
    <td>id</td>
    <td><input name="fid" type="text" value=""/></td>
    <td>是</td>
    <td>int</td>
    <td>钓场ID</td>
  </tr>

  <tr bgcolor="#F9F9F9" height="24">
    <td colspan="5" align="center"><input type="button" value="提交" onclick="request()"/></td>
  </tr>
  </form>
</table>
<script language="javascript">

var isAuth = <?php echo $api["isAuth"] ? 'true' : 'false'?>;
var api_id = <?php echo $api["id"]?>;
var url = "<?php echo $api["url"]?>";
var method = "<?php echo $api["method"]?>";
	
function request(){
	
	var api_host_obj = $('#api_host');
	
	var $form = $('#requestform');
	
	$form.attr('method', method);

	if(isAuth){
		var api_host = $('<input type="text" name="api_host" value="'+api_host_obj.val()+'"/>');
		$form.append($('<input type="text" name="api_id" value="'+api_id+'"/>'));  
		$form.append(api_host);  
		$form.attr('action', "/FishingField/asyncInfo");
	}else{
		$form.attr('action', api_host.val()+url);
	}
	
	$form.submit();

}


</script>
</body>
</html>